<template>
     <ztree  :data="data"
            @nodeClick="nodeClick"
            :name="'departName'" id="bbb">
            </ztree>
</template>
<script>
import ztree from "./index";

export default {
  props: {
    onlyProject: {
      type: Boolean,
      default: true
    }
  },
  components: {
    ztree
  },
  data() {
    return {
      data: []
    };
  },
  mounted() {
            let that = this;
            if (that.$store.state.departType == 5) {
              that.$axiosAjax
                .getBuildRelationProject({ parentId: that.$store.state.departId })
                .then(res => {
                  if (res.data.success == true) {
                    that.data = res.data.result;
                  }
                })
                .catch(err => {});
            } else {
              that.$axiosAjax
                .examinedUnits({ parentId: that.$store.state.departId })
                .then(res => {
                  if (res.data.success == true) {
                    that.data = res.data.result;
                  }
                })
                .catch(err => {});
            }
 
  },
  methods: {
        connectWebViewJavascriptBridge(callback) {
            if (window.WebViewJavascriptBridge) {
                callback(WebViewJavascriptBridge);
            } else {
                document.addEventListener(
                "WebViewJavascriptBridgeReady",
                function() {
                    callback(WebViewJavascriptBridge);
                },
                false
                );
            }
        },
    nodeClick(data) {   
      document.getElementsByClassName('weui-mask_transparent')[0].style.zIndex=600;
      document.getElementsByClassName('weui-toast')[0].style.zIndex=601;
      if (this.onlyProject) {
        if (data.departType < 6) {
          this.$vux.toast.show({
            type:'warn',
            text: "只能选择项目部"
          });
          return;
        }
      }
      this.$emit("nodeClick", data);
    }
  }
};
</script>